home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 51 / Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso / -in_the_mag- / workbench / term_4.8 / extras / source / gtlayout-source.lha / LT_NewMenuTemplate.c < prev    next >
C/C++ Source or Header  |  1997-05-08  |  3KB  |  127 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1997 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. #ifdef DO_MENUS
  17.  
  18. /****** gtlayout.library/LT_NewMenuTemplate ******************************************
  19. *
  20. *   NAME
  21. *    LT_NewMenuTemplate -- Allocate and layout menu items (V11)
  22. *
  23. *   SYNOPSIS
  24. *    Menu = LT_NewMenuTemplate(Screen,TextAttr,AmigaGlyph,CheckmarkGlyph,
  25. *     D0                         A0      A1        A2           A3
  26. *
  27. *                              Error,MenuTemplate);
  28. *                                D0      D1
  29. *
  30. *    struct Menu *LT_NewMenuTemplate(struct Screen *,struct TextAttr *,
  31. *                                    struct Image *,struct Image *,
  32. *                                    LONG *,struct NewMenu *);
  33. *
  34. *   FUNCTION
  35. *    Allocates Menus and MenuItems similar to LT_LayoutMenus().
  36. *
  37. *    As of v18 this routine will validate menu mutual exclusion
  38. *    information.
  39. *
  40. *   INPUTS
  41. *    Screen - Pointer to the screen the menu will appear on. This
  42. *        parameter is required and must not be omitted.
  43. *
  44. *    TextAttr - Pointer to the TextAttr that should be used to
  45. *        layout the menus. If this parameter is omitted,
  46. *        Screen->Font will be used instead.
  47. *
  48. *    AmigaGlyph - Pointer to the Image to use as the Amiga glyph.
  49. *        This parameter may be omitted.
  50. *
  51. *            NOTE: Ignored by intuition.library v37 and below.
  52. *
  53. *    CheckmarkGlyph - Pointer to the Image to use as the checkmark
  54. *        glyph. This parameter may be omitted.
  55. *
  56. *    Error - Pointer to receive error code in case the menu
  57. *        creation or layout process fails. This parameter
  58. *        may be omitted.
  59. *
  60. *    MenuTemplate - Pointer to a series of NewMenu structures,
  61. *        just as you would pass to
  62. *        gtlayout.library/LT_LayoutMenuA.
  63. *
  64. *   RESULT
  65. *    Menu - Pointer to Menu structure, ready to pass to
  66. *        SetMenuStrip(), NULL on failure.
  67. *
  68. *   NOTES
  69. *    The menu created by this function cannot be used with the
  70. *    routines LT_MenuControlTagList, LT_FindMenuCommand and
  71. *    LT_GetMenuItem.
  72. *
  73. *    You may freely add, remove, spindle & mutilate the contents of the
  74. *    menu strip created, just don't trash or disconnect the base menu
  75. *    entry this routine creates as all menu memory tracking data is
  76. *    connected with it.
  77. *
  78. *   SEE ALSO
  79. *    gtlayout.library/LT_DisposeMenu
  80. *    gtlayout.library/LT_LayoutMenuA
  81. *    gtlayout.library/LT_NewMenuTagList
  82. *    intuition.library/SetMenuStrip
  83. *
  84. ******************************************************************************
  85. *
  86. */
  87.  
  88. struct Menu * LIBENT
  89. LT_NewMenuTemplate(REG(a0) struct Screen *Screen,REG(a1) struct TextAttr *TextAttr,REG(a2) struct Image *AmigaGlyph,REG(a3) struct Image *CheckGlyph,REG(d0) LONG *ErrorPtr,REG(d1) struct NewMenu *MenuTemplate)
  90. {
  91.     LONG Error;
  92.  
  93.     if(ErrorPtr)
  94.         *ErrorPtr = 0;
  95.  
  96.     if(MenuTemplate)
  97.     {
  98.         RootMenu *Root;
  99.  
  100.         if(Root = LTP_NewMenu(Screen,TextAttr,AmigaGlyph,CheckGlyph,&Error))
  101.         {
  102.                 // Create the menu
  103.  
  104.             if(LTP_CreateMenuTemplate(Root,&Error,MenuTemplate))
  105.             {
  106.                     // Do the layout
  107.  
  108.                 if(LTP_LayoutMenu(Root,2,2))
  109.                     return(&Root->Menu);
  110.                 else
  111.                     Error = ERROR_DISK_FULL;
  112.             }
  113.  
  114.             LT_DisposeMenu(&Root->Menu);
  115.         }
  116.     }
  117.     else
  118.         Error = ERROR_REQUIRED_ARG_MISSING;
  119.  
  120.     if(ErrorPtr)
  121.         *ErrorPtr = Error;
  122.  
  123.     return(NULL);
  124. }
  125.  
  126. #endif    /* DO_MENUS */
  127.